package com.ssy.invoicing.suppliers.dao;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.ssy.invoicing.dao.support.BaseSqlDao;
import com.ssy.invoicing.suppliers.bean.SuppliersBean;

/**
 * Comment of CustomerDao
 * @author suoyao.shen
 */
@Repository(value="suppliersDao")
public class SuppliersDao extends BaseSqlDao {

    /**
     * 查询供应商信息列表,分页
     * @author suoyao.shen
     * @param params
     * @param page
     * @return
     * @throws SQLException
     */
    public SplitPageResult querySuppliersListByPage(Map<String, Object> params, int page)
            throws SQLException {
        return queryListByPagination("suppliers.querySuppliersListByPage", "suppliers.querySuppliersCount",
                params, page);
    }
    
    /**
     * 查询供应商列表
     * @author suoyao.shen
     * @return
     */
    @SuppressWarnings("unchecked")
    public List<SuppliersBean> querySuppliersList() {
        return (List<SuppliersBean>) queryForList("suppliers.querySuppliersList");
    }
    
    /**
     * 查询供应商详情
     * @author suoyao.shen
     * @param id
     * @return
     */
    public SuppliersBean getSuppliers(Integer id) {
        return (SuppliersBean) queryForObject("suppliers.getSuppliers", id);
    }
    
    /**
     * 删除供应商信息
     * @author suoyao.shen
     * @param id
     */
    public void removeSuppliers(Integer id) {
        delete("suppliers.removeSuppliers", id);
    }
    
    /**
     * 保存供应商信息
     * @param suppliers
     */
    public void saveSuppliers(SuppliersBean suppliers) {
        update("suppliers.insertSuppliers", suppliers);
    }
    
    /**
     * 更新供应商信息
     * @param suppliers
     */
    public void updateSuppliers(SuppliersBean suppliers) {
        update("suppliers.updateSuppliers", suppliers);
    }
    
}
